package ex2.ccf.threadFind;

import java.util.Scanner;

/**
 * @AUTHOR 尹书岿
 * @DATE 2024/12/10 21:01
 * @DESCRIBE
 */
public class threadFind {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int t = sc.nextInt();

        int xl = sc.nextInt();
        int yd = sc.nextInt();
        int xr = sc.nextInt();
        int yu = sc.nextInt();

        //经过的人数
        int rep = 0;
        //逗留人数
        int res = 0;
        int[] max = new int[n];

        for (int i = 0; i < n; i++){
            int cut = 0;  //记录这个居民持续在内部逗留的次数
            max[i] = -1;  //标记最大的持续逗留次数
            for (int j=0 ; j<t ; j++){
                int x = sc.nextInt();
                int y = sc.nextInt();
                if (x>=xl && x<=xr && y>=yd && y<= yu){
                    cut++;
                    if (max[i] < cut){
                        max[i] = cut;
                    }
                }
                else {
                    cut = 0;
                }
            }
            if (max[i] >=1 && max[i]<k){
                rep++;
            } else if (max[i] >= k) {
                res++;
            }
        }
        System.out.println(rep+res);
        System.out.println(res);

    }
}
